package puan.com.weighBox.presenter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.blankj.utilcode.util.ActivityUtils;

import androidx.appcompat.widget.Toolbar;
import puan.com.weighBox.R;
import puan.com.weighBox.activity.OperatorRecordsActivity;
import puan.com.weighBox.activity.SettingActivity;
import puan.com.weighBox.activity.UserInfoActivity;
import puan.com.weighBox.viewInterface.IAdminView;

public class AdminPresenter {

    private IAdminView iAdminView;

    public AdminPresenter(IAdminView iAdminView) {
        this.iAdminView = iAdminView;
    }

    public void showMorePopupwindow(Context context, Toolbar toolbar) {

        View view = View.inflate(context, R.layout.more_option_layout, null);
        PopupWindow popupWindow = new PopupWindow(view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, false);

        popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        popupWindow.setOutsideTouchable(true);
        popupWindow.setTouchable(true);
        popupWindow.showAsDropDown(toolbar, 0, 0, Gravity.RIGHT);

        TextView tvUserInfo = view.findViewById(R.id.tvUserInfo);
        TextView tvSearch = view.findViewById(R.id.tvSearch);
        TextView tvSetting = view.findViewById(R.id.tvSetting);
        tvUserInfo.setOnClickListener(v -> {
            ActivityUtils.startActivity(new Intent(context, UserInfoActivity.class));
            popupWindow.dismiss();
        });
        tvSearch.setOnClickListener(v -> {
            ActivityUtils.startActivity(new Intent(context, OperatorRecordsActivity.class));
            popupWindow.dismiss();
        });
        tvSetting.setOnClickListener(v -> {
            ActivityUtils.startActivity(new Intent(context, SettingActivity.class));
            popupWindow.dismiss();
        });
    }

}
